#version 130

uniform int radius;
uniform vec2 movement;
uniform sampler2D tex;

in vec2 fragmentTexCoord;

out vec4 fragColor;

float getGauss(float difference, float variance)
{
	return exp(-difference*difference/(2*variance*variance));
}

void main(void) {
	vec4 color = texture(tex, fragmentTexCoord);
	float weight = 1.0f;

	vec2 m = (movement)/textureSize(tex,0);
        

	vec2 currPosition;
	float currWeight;
	for(int i = 0; i<radius; i++){
                
		//right
		currPosition = fragmentTexCoord + i*m;
		currWeight = getGauss(i, radius*0.5);
		color += texture(tex, currPosition)*currWeight;
		weight += currWeight;

		//right
		currPosition = fragmentTexCoord - i*m;
		currWeight = getGauss(i, radius*0.5);
		color += texture(tex, currPosition)*currWeight;
		weight += currWeight;
	}

        

	fragColor = color/weight;	
}
